<template>
    <div class="reports">
        <el-card>
            <!-- 2、为ECharts准备一个具备大小（宽高）的Dom -->
            <div id="main" style="width: 750px;height:400px;"></div>
        </el-card>
    </div>
</template>

<script>
import { getreports } from "../utils/orders"
import * as echarts from 'echarts';
import _ from 'lodash'
export default {
    data() {
        return {
            options: {
                title: {
                    text: '用户来源'
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        label: {
                            backgroundColor: '#E9EEF3'
                        }
                    }
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        boundaryGap: false
                    }
                ],
                yAxis: [
                    {
                        type: 'value'
                    }
                ]
            }
        }
    },
    methods: {

    },
    created() {
        getreports().then(res => {
            console.log(21, res);       
            if(res.meta.status !== 200) return this.$message.error('获取折线图数据失败！');
            var myChart = echarts.init(document.getElementById('main'));
            const result = _.merge(res.data, this.options);
            myChart.setOption(result)
        })
    },
    mounted() {
        
    },
    components: {

    },
    computed: {

    },
    watch: {

    },
}
</script>

<style lang='scss' scoped>
.reports {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    background-color: #fff;
}
</style>
